<template lang="pug">
  el-form(:model="guiji" label-position="right" label-width="100px")
    el-form-item(label="添加个人轨迹")
    el-form-item(label="到达时间")
      el-date-picker(v-model="guiji.createtime" type="datetime" placeholder="请选择时间" value-format="yyyy-MM-dd HH:mm:ss")
    el-form-item(label="地区")
      el-input(v-model="guiji.address" placeholder="请输入地区")
    el-form-item(label="地点风险")
      el-radio(v-model="guiji.risk" label="1") 高风险
      el-radio(v-model="guiji.risk" label="2") 中风险
      el-radio(v-model="guiji.risk" label="3") 低风险
    el-form-item(label="去程交通工具")
      el-input(v-model='guiji.vehicle' placeholder="请输入交通工具")
    el-form-item(label="交通工具号")
      el-input(v-model='guiji.vehicleno' placeholder="请输入交通工具号")
    el-form-item(label="是否有风险")
      el-radio(v-model="guiji.isrisk" label="0") 无风险
      el-radio(v-model="guiji.isrisk" label="1") 有风险
    el-form-item
      el-button(type="primary" @click="submitGuiji") 提交
</template>
<script>
export default {
  data() {
    return {
      guiji: {
        createtime: '',
        address: '',
        risk: '',
        vehicle: '',
        vehicleno: '',
        isrisk: '',
      }
    }
  },
  mounted() {
    if (this.$route.query.id) {
      console.log('轨迹回显信息', this.$store.state.guijiItem)
      this.guiji = this.$store.state.guijiItem
    }
  },
  methods: {
    //添加轨迹 修改
    submitGuiji() {
      if (this.$route.query.id) {
        this.editSubmitGuiji()
      } else {
        this.$http('track/saveorupdate', {
          ...this.guiji,
          personid: this.$route.query.personId
        }, 'POST').then(res => {
          this.$notify.success(res.message)
          this.$router.push(
            {
              path: '/monitorDetails',
              query: {
                personId: this.$route.query.personId,
                type: this.$route.query.type
              }
            }
          )
        })      }
    },
    //修改轨迹
    editSubmitGuiji() {

      this.$http('track/saveorupdate', {
        ...this.guiji,
        personid: this.$route.query.personId,
        id: this.$route.query.id
      }, 'POST').then(res => {
        this.$notify.success(res.message)
        this.$router.push(
          {
            path: '/monitorDetails',
            query: {
              personId: this.$route.query.personId,
              type: this.$route.query.type
            }
          }
        )
      })
    },
  }
}
</script>

<style scoped>
.el-form {
	color: #fff;
	width: 60%;
	/* display: flex;
	justify-content: center;
	align-items: center;
	flex-direction: column;
	box-sizing: border-box;
	background: #fff; */
}
>>> .el-form-item__label {
	color: #fff;
}
</style>

